using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class TowerArrow : MonoBehaviour
{
    public float liveTime = 6f;    
    public int damage = 2;
    private void Update(){
        transform.position += transform.up * ShootTower.shootTower.arrowSpeed * Time.deltaTime;  
        liveTime -= Time.deltaTime;
        if(liveTime <= 0 ){
            Destroy(gameObject);
        }
    }

    public void OnTriggerStay2D(Collider2D other)
    {
        if(other.CompareTag("Enemy")){
            Debug.Log("发现敌人");
            var enemy = other.gameObject.GetComponent<SuperEnemies>();
            if(enemy.HP != 0){
                enemy.GetHurt(damage);
                Destroy(gameObject);
            }
        }
    }
}
